<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="/WEB-INF/templates/templateMenu.xhtml">
	<ui:define name="body">
		<a4j:form>
			<rich:toolBar>
				<h:outputText styleClass="texto_negrito"
					value="Cadastro e Manutenção de Contas" />
				<rich:toolBarGroup location="right">
					<a4j:commandLink action="#{contaBean.gravar}" rendered="#{empty rendered_btgravar ? true : rendered_btgravar}"
						reRender="tblConta,panelCadConta">
						<h:graphicImage style="border: none;" url="/imagens/disk.png" />
						<h:outputText value="Gravar" />
					</a4j:commandLink>
				</rich:toolBarGroup>
			</rich:toolBar>
			
			<h:panelGrid columns="3" id="panelCadConta">
				<h:outputLabel value="Nome" />
				<h:inputText value="#{contaBean.conta.nome}" required="true" id="inpNome">
					
				</h:inputText>
				<rich:message for="inpNome"/>
				<h:outputLabel value="Tipo"  />
				<h:inputText value="#{contaBean.conta.tipo}" required="true" id="inpTipo">
					
				</h:inputText>
				<rich:message for="inpTipo"/>
				<h:outputLabel value="Descrição" />
				<h:inputTextarea  value="#{contaBean.conta.descricao}" id="inpDescricao">
					
				</h:inputTextarea>
				<rich:message for="inpDescricao"/>
			</h:panelGrid>
			<rich:separator height="8" width="100%" lineType="beveled"></rich:separator>
			<h:panelGrid width="100%">
				<rich:dataTable value="#{contaBean.listaContas}" id="tblConta" var="conta" width="100%" binding="#{contaBean.tblConta}" rowClasses="tb_cor2,tb_cor1" rows="10" cellspacing="5">
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Nome" />
						</f:facet>
						<h:outputText value="#{conta.nome}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Tipo" />
						</f:facet>
						<h:outputText value="#{conta.tipo}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Descrição" />
						</f:facet>
						<h:outputText value="#{conta.descricao}" />
					</rich:column>
					<rich:column>
						<f:facet name="header">
							<h:outputText value="Ações" />
						</f:facet>
						<h:panelGrid columns="3" cellpadding="5">
							<a4j:commandLink ajaxSingle="true" action="#{contaBean.delete}" reRender="tblConta,panelCadConta">
								<h:graphicImage border="0" value="/imagens/delete.png" />
								<h:outputText value="Excluir" />
							</a4j:commandLink>

							<a4j:commandLink ajaxSingle="true"	action="#{contaBean.edicaoConta}">
								<h:graphicImage border="0" value="/imagens/edit.png" />
								<h:outputText value="Alterar" />
							</a4j:commandLink>
							
							<a4j:commandLink ajaxSingle="true"	action="#{contaBean.exibirDetalhes}">
								<h:graphicImage border="0" value="/imagens/detalhe.png" />
								<h:outputText value="Detalhes" />
							</a4j:commandLink>
						</h:panelGrid>
					</rich:column>
				</rich:dataTable>
			</h:panelGrid>
			<rich:datascroller for="tblConta"/>
		</a4j:form>
	</ui:define>

</ui:composition>

</html>